#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <sstream>
using namespace std;

#include <stdio.h>

void dealOutput(const string &param1
				, const string &param2
				, string &out)
{
	out += "\n\t";
	out += param1;
	out += " = ";
	out += param2;
	out += ",";
}

void dealModeInfo() {
    ifstream file ( "/home/michael/Desktop/1.csv" );
    string value;

    string output = "{";
    int count = 0;
    string lateNum = "";	// enum value

    bool hasSign = false;
    while ( file.good() )
    {
        getline ( file, value);
        cout << count << " " << value << endl;
        count++;

        int latePos = value.find(",");
        if (latePos >= 0) {
        	string temp = "";

        	if (latePos > 0) {
        		temp = string(value, 0, latePos);
	        	if (lateNum == temp) {
	        		lateNum += "\t // TODO: same id";
	        	}
	        	else {
	        		lateNum = temp;
	        	}
        	}
        	else {
        		lateNum += "\t // TODO: same id";
        	}
        	 
        	int signPos = value.find("\"");
        	if (signPos >= 0) {
        		if (signPos == 0) {
					lateNum += "\t // TODO: same id";
        		}
        		hasSign = true;
        	}
        	else {
        		dealOutput(string(value, latePos + 1), lateNum, output);
        	}
        }
        else {
        	if (hasSign) {
        		if (value.find("\"") >= 0) {
        			hasSign = false;
        		}

        		int pos = value.find("\"");
        		dealOutput(string(value, 0, pos), lateNum, output);
        	}


        }
    }
    output.append("\n}");
    cout << output << endl;
}

void getModeInfo()
{
    ifstream file ( "/home/michael/Desktop/mainappho.csv" );
    string value;

    string output = "{";
    int count = 0;
    string lateNum = "";	// enum value

    bool hasSign = false;
    while ( file.good() )
    {
        getline ( file, value, ',');
        cout << count << " " << value << endl;
        count++;
    }
}

int main(int argc, char *argv[]) 
{
    dealModeInfo();
}